﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Joyintech.Common;
using Joyintech.Model.inpiao365;
using Joyintech.BLL.inpiao365;
using Joyintech.Common.DEncrypt;

namespace Joyintech.Admin.inpiao365.general
{
    public partial class changePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (this.txtPassNew1.Text.Trim() != this.txtPassNew2.Text.Trim())
            {
                MessageBox.Show(this, "两次密码不一致！");
                return;
            }

            systemUser model = new systemUser();

            model = new systemUser_BLL().GetModel(systemUser_BLL.GetInstance().GetCurrentSystemUser().UserId);

            if (model != null && model.UserPassword == DEncrypt.Encrypt(this.txtPassOld.Text.Trim()))
            {
                int Num = new systemUser_BLL().Update(model.UserId, DEncrypt.Encrypt(this.txtPassNew1.Text.Trim()));

                if (Num == 1)
                {
                    MessageBox.Show(this, "密码修改成功！");
                }
            }
            else
            {
                MessageBox.Show(this, "原密码错误，请重试！");
            }
        }
    }
}